package com.CollectionJiHe.SetAPI;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class SetStudentTest {
    public static void main(String[] args) {
        Set<Student>students=new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return Double.compare(o1.getHeight(),o2.getHeight());
            }
        });//就近选择构造器进行排序。
        students.add(new Student("石昊",19,1.83));
        students.add(new Student("萧炎",18,1.85));
        students.add(new Student("夜葬",21,1.80));
        students.add(new Student("马克",22,1.89));

        System.out.println(students);
    }
}
